package com.wzy.java;

import java.util.ArrayList;
import java.util.Iterator;

public class test26 {
    public static void main(String[] args) {
        // 创建一个数组
        ArrayList<Integer> numbers = new ArrayList<>();

        // 往数组中添加元素
        numbers.add(1);
        numbers.add(2);
        numbers.add(3);
        numbers.add(4);
        System.out.println("ArrayList: " + numbers);

        // 所有元素乘以 10
        System.out.print("更新 ArrayList: ");
        // 将 lambda 表达式传递给 forEach
        numbers.forEach(e -> {
            e = e * 10;
            System.out.print(e + " ");
        });
        System.out.println();
        Iterator<Integer> iterator = numbers.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }

        numbers.forEach(item->{
            System.out.println(item);
        });
    }
}
